
module global_rst #(
	parameter RESET_KEEP_CYCLE = 8,			//复位信号最小保持周期
	parameter BUSY_KEEP_CYCLE = 60			//复位忙标志保持周期
)
(
	input sys_clk,							//时钟
	input sys_rst_n,						//外部输入的复位信号

	output global_rst_n,					//全局复位信号
	output rst_busy							//复位忙标志
);

//计数器，进行复位信号延长计时
reg [31:0] count;

//进行递增计数，用于延迟复位信号，输出复位完成信号
always @(posedge sys_clk) begin
	if(!sys_rst_n)
		count <= 0;
	else if(count < (RESET_KEEP_CYCLE + BUSY_KEEP_CYCLE + 1))
		count = count + 1;
end

//输出经过延迟的全局复位信号
assign global_rst_n = ((sys_rst_n == 1) && (count > RESET_KEEP_CYCLE)) ? 1 : 0;

//输出复位忙标志
assign rst_busy = ((sys_rst_n == 1) && (count > (RESET_KEEP_CYCLE + BUSY_KEEP_CYCLE))) ? 0 : 1;

endmodule
